namespace Hack.Decompiling.PEA.CLR
{
  using System;
  using System.IO;
  using System.Collections.Generic;
  using System.Text;
  using PEA.PE;

  public enum HeapIndex:byte
  {
    LargeStringHeap = 0x01,
    LargeGuidHeap = 0x02,
    LargeBlobHeap = 0x04,
  }
  public class MetadataTablesHeader
  {
    #region Consts
    public static Byte DefaultMajorVersion = 2;
    public static Byte DefaultMinorVersion = 0;
    #endregion
    #region Fields
    /// <summary>
    /// Reserved, always 0
    /// </summary>
    protected UInt32 _Reserved = 0;
    /// <summary>
    /// Major version of table schemata
    /// </summary>
    protected Byte _MajorVersion = DefaultMajorVersion;
    /// <summary>
    /// Minor version of table schemata
    /// </summary>
    protected Byte _MinorVersion = DefaultMinorVersion;
    /// <summary>
    /// Bit vector for heap sizes.
    /// </summary>
    protected Byte _HeapSizes = 0;
    /// <summary>
    /// Reserved, always 1 (see Section 23.1).
    /// </summary>
    protected Byte _Reserved2 = 1;
    /// <summary>
    /// Valid, Bit vector of present tables, let n be the number of bits that are 1.
    /// </summary>
    protected UInt64 _Valid = 0;
    /// <summary>
    /// Sorted, Bit vector of sorted tables.
    /// </summary>
    protected UInt64 _Sorted = 0;
    /// <summary>
    /// Tables including(Rows)
    /// The sequence of physical tables.
    /// Rows,Array of n four byte unsigned integers indicating the number of rows for each present table.
    /// </summary>
    /// <remarks>
    /// Following this, there's an array of DWORDs with the number of rows for each table present. 
    /// OK, this has to be explained. For every table, there can be n rows.
    /// Let's say we have three tables: A, B, and C. And the Valid mask tells us that the B table is not present,
    /// but A and C are. In this case, there will be two DWORDs (not three), 
    /// one for the rows in the A table and one for the C table.
    /// The B table rows are skipped since there is no B table in the assembly.
    /// </remarks>
    protected IList<MetadataTable> tables = null;
    #endregion
    #region Properties
    #endregion
  }
}
